package translate;

import temp.Label;
import temp.Temp;
import tree.MOVE;
import tree.SEQ;
import tree.Stm;

abstract public class Cx extends Exp {
	@Override
	public tree.Exp unEx() {
		Temp r = new Temp();
		Label t = new Label();
		Label f = new Label();
		
		return new tree.ESEQ(
				new tree.SEQ(new tree.MOVE(new tree.TEMP(r), new tree.CONST(1)),
							 new tree.SEQ(unCx(t, f), 
									 new tree.SEQ(new tree.LABEL(f),
											 	  new tree.SEQ(new tree.MOVE(new tree.TEMP(r), 
											 			  	   new tree.CONST(0)),
									 new tree.LABEL(t))))),
				new tree.TEMP(r));
	}

	@Override
	public Stm unNx() {
		// TODO Auto-generated method stub
		return null;
	}

	public abstract Stm unCx(Label t, Label f);

}
